package hczc.longcai.com.hccrowdfunding.home.second_invest.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import hczc.longcai.com.hccrowdfunding.R;
import hczc.longcai.com.hccrowdfunding.activity.BaseActivity;
import hczc.longcai.com.hccrowdfunding.application.BaseApplication;
import hczc.longcai.com.hccrowdfunding.home.second_invest.adapters.ProjectDetailsAdapter;
import hczc.longcai.com.hccrowdfunding.home.second_invest.beans.ProjectDetail;

public class ProjectDetailsActivity extends BaseActivity implements View.OnClickListener, ProjectDetailsAdapter.CallBack {

    private static final String TAG = "ProjectDetailsActivity";
    private View back;
    private TextView title;
    private ListView listView;
    private List<ProjectDetail> details;
    private ProjectDetailsAdapter adapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_project_details);

        initDatas();
        initViews();
    }

    private void initDatas() {
        details = new ArrayList<>();
        ProjectDetail detail1 = new ProjectDetail();
        detail1.setType(1);
        detail1.setTitle("镭射眼只能行车记录仪");
        details.add(detail1);
        ProjectDetail detailFengexian1 = new ProjectDetail();
        detailFengexian1.setType(9);
        details.add(detailFengexian1);
        ProjectDetail detail2 = new ProjectDetail();
        detail2.setType(2);
        details.add(detail2);
        ProjectDetail detailFengexian2 = new ProjectDetail();
        detailFengexian2.setType(9);
        details.add(detailFengexian2);
        ProjectDetail detail3 = new ProjectDetail();
        detail3.setType(3);
        details.add(detail3);
        ProjectDetail detailFengexian3 = new ProjectDetail();
        detailFengexian3.setType(9);
        details.add(detailFengexian3);
        ProjectDetail detail4 = new ProjectDetail();
        detail4.setType(4);
        details.add(detail4);
        ProjectDetail detailFengexian4 = new ProjectDetail();
        detailFengexian4.setType(9);
        details.add(detailFengexian4);
        ProjectDetail detail5 = new ProjectDetail();
        detail5.setType(5);
        details.add(detail5);
        ProjectDetail detailFengexian5 = new ProjectDetail();
        detailFengexian5.setType(9);
        details.add(detailFengexian5);
        ProjectDetail detail6 = new ProjectDetail();
        detail6.setType(6);
        details.add(detail6);
        ProjectDetail detailFengexian6 = new ProjectDetail();
        detailFengexian6.setType(9);
        details.add(detailFengexian6);
        ProjectDetail detail7 = new ProjectDetail();
        detail7.setType(7);
        details.add(detail7);
        ProjectDetail detailFengexian7 = new ProjectDetail();
        detailFengexian7.setType(9);
        details.add(detailFengexian7);
        ProjectDetail detail8 = new ProjectDetail();
        detail8.setType(8);
        details.add(detail8);
        ProjectDetail detailFengexian8 = new ProjectDetail();
        detailFengexian8.setType(9);
        details.add(detailFengexian8);

    }

    private void initViews() {
        back = findViewById(R.id.head_back);
        back.setOnClickListener(this);
        title = ((TextView) findViewById(R.id.head_title));
        title.setText("H基金");
        findViewById(R.id.head_right_pic).setVisibility(View.GONE);

        listView = ((ListView) findViewById(R.id.invest_details_listview));
        View view = LayoutInflater.from(this).inflate(R.layout.item_details_listview_header, listView, false);
        BaseApplication.scaleScreenHelper.loadView(((ViewGroup) view));

        listView.addHeaderView(view);
        adapter = new ProjectDetailsAdapter(ProjectDetailsActivity.this,details,this);
        listView.setAdapter(adapter);


    }

    @Override
    public void onClick(View view) {
        int index = view.getId();
        switch (index){
            case R.id.head_back:
                finish();
                break;
        }
    }

    @Override
    public void click(View view) {
        int id = view.getId();
        switch (id){
            case R.id.detail_listview_attention:
//                Toast.makeText(ProjectDetailsActivity.this,"点击了关注按钮",Toast.LENGTH_SHORT).show();
                break;
            case R.id.detail_listview_zan:
//                Toast.makeText(ProjectDetailsActivity.this,"点击了赞按钮",Toast.LENGTH_SHORT).show();
                break;
            case R.id.detail_listview_xmsm:
//                Toast.makeText(ProjectDetailsActivity.this,"点击了项目说明",Toast.LENGTH_SHORT).show();
                break;
            case R.id.detail_listview_xmjz_all:
//                Toast.makeText(ProjectDetailsActivity.this,"点击了查看全部动态",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(ProjectDetailsActivity.this,ProjectDynamicActivity.class));
                break;
            case R.id.detail_listview_comment_all:
//                Toast.makeText(ProjectDetailsActivity.this,"点击了查看所有评论",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(ProjectDetailsActivity.this,ProjectCommentActivity.class));
                break;
        }
    }
}
